Skip to content

Comments

Facebook Messenger Connector#9

Merged
tsutomi merged 2 commits intomainfrom
feature-fbmessenger
Aug 16, 2025
Merged

Facebook Messenger Connector#9
tsutomi merged 2 commits intomainfrom
feature-fbmessenger

Conversation

@tsutomi
Copy link
Member

@tsutomi tsutomi commented Aug 16, 2025

This pull request introduces support for Facebook Messenger as a new messaging connector in the Deveel Messaging Framework. The changes include updates to the solution and documentation, as well as the addition of new project files and code for Facebook Messenger integration. The most important changes are grouped below:

Solution and Project Structure

  • Added Deveel.Messaging.Connector.Facebook and its associated test project Deveel.Messaging.Connector.Facebook.XUnit to the solution file Deveel.Messaging.Model.sln, including build configurations and project nesting. [1] [2] [3]
  • Created new project file Deveel.Messaging.Connector.Facebook.csproj with dependencies on RestSharp and Microsoft.Extensions.Http.

Documentation Updates

  • Updated main documentation (docs/README.md and docs/connectors/README.md) to include Facebook Messenger in connector lists, feature matrices, installation instructions, and use case recommendations. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]
  • Added code samples and documentation for Facebook Messenger schema and integration, including connector capabilities and example usage in NotificationService. [1] [2] [3]

Connector Features and Capabilities

  • Documented new Facebook Messenger features: interactive messaging, quick replies, media attachments, health monitoring, and compliance with Facebook Graph API v21.0.
  • Expanded capability and use case matrices to include Facebook Messenger, highlighting its support for interactive elements and bidirectional communication. [1] [2] [3]

Code Additions

  • Added core attachment model for Facebook messages (FacebookAttachment and FacebookPayload).
  • Minor fix to StatusInfo constructor to properly assign the description field.

These changes collectively enable Facebook Messenger integration in the framework, update documentation for discoverability, and lay the foundation for development and testing of Facebook messaging features.

@tsutomi tsutomi self-assigned this Aug 16, 2025
Copilot AI review requested due to automatic review settings August 16, 2025 11:46
@tsutomi tsutomi added the enhancement New feature or request label Aug 16, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request introduces comprehensive support for Facebook Messenger as a new messaging connector in the Deveel Messaging Framework. The integration includes full Facebook Graph API v21.0 compliance with RestSharp HTTP client, bidirectional messaging capabilities, and extensive test coverage.

  • Full Facebook Messenger Platform integration with Graph API v21.0 support
  • Complete connector implementation with send/receive messaging, media attachments, and health monitoring
  • Comprehensive test suite with unit, integration, and edge case coverage

Reviewed Changes

Copilot reviewed 26 out of 26 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
Solution and project files Added Facebook connector projects to solution with proper build configurations
Core connector implementation FacebookMessengerConnector with full messaging capabilities and error handling
Facebook service layer RestSharp-based FacebookService for Graph API operations
Model classes Facebook-specific message models (requests, responses, attachments, quick replies)
Schema definitions Channel schemas for different Facebook Messenger use cases
Test projects Comprehensive test coverage including unit, integration, and edge case tests
Documentation Complete connector documentation with usage examples and API reference

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

Assert.False((bool)method!.Invoke(null, new object[] { "" })!);
Assert.False((bool)method.Invoke(null, new object[] { "short" })!);
Assert.False((bool)method.Invoke(null, new object[] { "token with spaces" })!);
Assert.False((bool)method.Invoke(null, new object[] { " " })!);
Copy link

Copilot AI Aug 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using reflection to test private methods makes tests brittle and tightly coupled to implementation details. Consider making the validation method internal and using InternalsVisibleTo attribute, or testing the validation indirectly through public methods.

Suggested change
Assert.False((bool)method.Invoke(null, new object[] { " " })!);
// Test valid token formats directly
Assert.True(FacebookService.IsValidPageAccessToken("EAATest123456789|ValidPageAccessToken"));
Assert.True(FacebookService.IsValidPageAccessToken("EAAGTest123456789abcdef"));
Assert.True(FacebookService.IsValidPageAccessToken("someLongTokenWithPipe|123456"));
}
[Fact]
public void ValidatePageAccessToken_InvalidTokens_ReturnsFalse()
{
// Test invalid token formats directly
Assert.False(FacebookService.IsValidPageAccessToken(""));
Assert.False(FacebookService.IsValidPageAccessToken("short"));
Assert.False(FacebookService.IsValidPageAccessToken("token with spaces"));
Assert.False(FacebookService.IsValidPageAccessToken(" "));

Copilot uses AI. Check for mistakes.
// Use reflection to test the private method
var method = typeof(FacebookService).GetMethod("BuildFacebookMessagePayload",
System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);

Copy link

Copilot AI Aug 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiple test methods use reflection to access private methods. This pattern is repeated throughout the test file, making tests fragile to refactoring. Consider exposing these methods as internal or testing through public API behavior.

Suggested change

Copilot uses AI. Check for mistakes.

// Assert
Assert.False(result.Successful);
Assert.Equal(ConnectorErrorCodes.GetStatusError, result.Error?.ErrorCode); // Fixed: Base class catches exceptions and converts to standard error code
Copy link

Copilot AI Aug 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment suggests this test assertion was 'fixed' but the comment indicates uncertainty about the expected behavior. The test should verify the actual expected error code based on the implementation, not guess based on comments.

Suggested change
Assert.Equal(ConnectorErrorCodes.GetStatusError, result.Error?.ErrorCode); // Fixed: Base class catches exceptions and converts to standard error code
// The base class catches exceptions from GetConnectorStatusAsync and returns ConnectorErrorCodes.GetStatusError (see FacebookMessengerConnector.GetStatusAsync implementation).
Assert.Equal(ConnectorErrorCodes.GetStatusError, result.Error?.ErrorCode);

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,7 @@
namespace Deveel.Messaging
Copy link

Copilot AI Aug 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The FacebookMessengerSchemaFactory class is missing copyright header and XML documentation comments that are present in other files in the project.

Copilot uses AI. Check for mistakes.
e.CanSend = true; // Allow EmailAddress so it passes schema validation
e.CanReceive = false;
e.IsRequired = false;
})
Copy link

Copilot AI Aug 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The EmailAddress endpoint type is allowed for sending with a comment indicating it's just to pass validation, but this could be confusing for API consumers. Consider either properly supporting email addresses or removing this endpoint type from the schema.

Suggested change
})

Copilot uses AI. Check for mistakes.
@tsutomi tsutomi merged commit ae3bbda into main Aug 16, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant